# vim: ts=4:sw=4:syntax=perl

use gri_secmgr qw(get_user_name);
use gri_portal_config;

sub mm_form_delete_portal_populate($$) {
my ($title,$filename)=@_;

	my $user_name=get_user_name();
	my ($rc,$err)=$::GRI_FRONTEND->does_user_have_role($user_name,'portal_admin');
	if(!$rc) {
		return "You do not have permissions to access this page.";
	}

	my $t2=hex_to_string($title);
	my $f2=hex_to_string($filename);
	my $portal_dir=$::GRI_FRONTEND->get_global_directory("portals");
	my $cportal=new gri_portal_config("$portal_dir/$f2");
	if(!defined($cportal)) {
		return "ERROR: No portal details defined.";
	}

	# Get the title, list of reports, users and template 
	my $users=$cportal->get_users();
	my $template=$cportal->get_template();
	my $reports=$cportal->get_reports();
	my $_reports="";
	if($reports && ref($reports)) {
		$_reports=join(",",sort(@$reports));
	}
	$template="" if !defined($template);
	if(!defined($users)) {
		$users="";
	} else {
		$users=join(",",@$users);
	}

	my $s="
   <tr>
     <td colspan=3 align=left>
       <font class=\"redSub14\">Portal Details</font>
     </td>
   </tr>
   <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
   </tr>  
   <tr>
     <td align=left><font class=label>Title:</font></td>
     <td>&nbsp;&nbsp;&nbsp;</td>
     <td align=left>
       <INPUT TYPE=\"hidden\" VALUE=\"$filename\" NAME=\"portal_name\" SIZE=\"60\" READONLY=\"1\">
       <INPUT TYPE=\"text\" VALUE=\"$t2\" NAME=\"title\" SIZE=\"60\" READONLY=\"1\">
     </td>
   </tr>
   <tr>
     <td colspan=3 align=left><font class=stdtextsmall>&nbsp;</font></td>
   </tr>
   <tr>
     <td align=left><font class=label>Reports:</td>
     <td>&nbsp;&nbsp;&nbsp;</td>
     <td align=left>
       <INPUT TYPE=\"text\" VALUE=\"$_reports\" NAME=\"count\" SIZE=\"60\" READONLY=\"1\">
     </td>
   </tr>
   <tr>
     <td colspan=3 align=left><font class=stdtextsmall>&nbsp;</font></td>
   </tr>
   <tr>
     <td align=left><font class=label>Template:</td>
     <td>&nbsp;&nbsp;&nbsp;</td>
     <td align=left>
       <INPUT TYPE=\"text\" VALUE=\"$template\" NAME=\"host\" SIZE=\"60\" READONLY=\"1\">
     </td>
   </tr>
   <tr>
     <td colspan=3 align=left><font class=stdtextsmall>&nbsp;</font></td>
   </tr>
   <tr>
     <td align=left><font class=label>Users:</td>
     <td>&nbsp;&nbsp;&nbsp;</td>
     <td align=left>
       <INPUT TYPE=\"text\" VALUE=\"$users\" NAME=\"type\" SIZE=\"60\" READONLY=\"1\">
     </td>
   </tr>
  ";
	
	return $s;
}

